package com;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;

public class Client extends UntypedActor{
	private ActorRef actor = null;
	
	@Override
    public void preStart() {
		ActorSystem system = ActorSystem.create("MySystem");
        // 创建一个名为child的子actor
		actor = system.actorOf(Props.apply(Server.class), "serverTemp");
       
    }

	public static void main(String[] args) {
		/*System.out.println("nimab    *************************** begin Client");
		akka.actor.ActorSystem.create(Server.AkkaSystemName, ConfigFactory.load().getConfig("client")).actorFor("akka://xw@127.0.0.1:25452/user/server").tell("hello,I'm client");
		System.out.println("nimab    *************************** over Client");*/
		
		/* ActorSystem system = ActorSystem.create("mySystem");
	        // 创建一个名为service的顶级actor
        system.actorOf(Props.apply(LookupActor.class), "service");
        // 使用绝对路径获取service
        ActorRef service = system.actorFor("akka://mySystem/user/service");
        service.tell("sss", null);*/
	}

	@Override
	public void onReceive(Object arg0) throws Exception {
		System.out.println("nimab    *************************** woshi Client");
		System.out.println("getSender()*********************"+getSender());
		actor.tell("bb jiao server ******",getSelf());
		 /*ActorSystem system = ActorSystem.create("mySystem1");
	        // 创建一个名为service的顶级actor
		 system.actorOf(Props.apply(Server.class), "serverTemp");
        // 使用相对路径
        ActorRef serverTemp = getContext().actorFor("serverTemp");
        serverTemp.tell("from parent 4", getSelf());
		getSender().tell("bb jiao server ******",getSelf());*/
	}

}
